﻿using ControlzEx.Theming;
using LiveCharts;
using Microsoft.Win32;
using SmartDevice.Library.Device.Voltmeter;
using SmartDevice.Models;
using Stylet;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace SmartDevice.Pages
{
    public class MainShellViewModel : Screen
    {
        protected override void OnViewLoaded()
        {
            base.OnViewLoaded();
            InitDevice();
        }

        public string VoltageInfo { get; set; }

        private readonly IVoltageVoltmeter dc300 = new DC300Voltmeter();

        private void InitDevice()
        {
            if (dc300.Connect("COM11"))
            {
                dc300.VoltagesReport += Dc300_VoltagesReport;
            }
        }

        private void Dc300_VoltagesReport(VoltageReportEventArgs args)
        {
            VoltageInfo = $"DC {args.Voltage:000} V";
        }
    }
}
